﻿<?xml version="1.0" encoding="utf-8" ?>
<mapping namespace="urn:Ordering.Service.Contract"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="ContractsMapping.xsd" >

  <!-- Add project references and namespaces to use here -->
  <reference project="Ordering.BusinessLayer"/>

  <!-- Namespace with alias "Contract" defines the contract types namespace -->
  <namespace name="Ordering.Service.Contract" alias="Contract" />

  <!-- Add namespaces to be imported in generated files -->

  <!-- Describe your mapping here -->
  <type name="OrderItem" source="Ordering.BusinessLayer.Order">
    <map property="OrderNumber" source="Id" identifier="true"></map>
    <map property="OrderDate"></map>
    <map property="CustomerId"></map>
    <map property="CustomerName" source="Customer.Name"></map>
    <map property="TotalOrderPrice"></map>
    <map property="ProductIds" source="OrderLines.ProductId"></map>
    <map property="ProductLabels" source="OrderLines.Product.Label"></map>
  </type>

  <type name="CustomerItem" source="Ordering.BusinessLayer.Customer"
        reverseMapping="referenceOnly">
    <map property="Id" identifier="true"></map>
    <map property="Name"></map>
    <map property="Email"></map>
    <map property="Address"></map>
  </type>

  <type name="OrderDetail" source="Ordering.BusinessLayer.Order"
        reverseMapping="createAndUpdate">
    <map property="OrderNumber" source="Id" identifier="true"></map>
    <map property="OrderDate"></map>
    <map property="Customer" type="CustomerItem" conversion="map"></map>
    <map property="OrderLines" type="OrderLineDetail"  conversion="map"
         onRemove="delete"></map>
  </type>

  <type name="OrderLineDetail" source="Ordering.BusinessLayer.OrderLine"
        reverseMapping="createAndUpdate">
    <map property="Id" identifier="true"></map>
    <map property="Product" type="ProductItem" conversion="map"></map>
    <map property="UnitPrice"></map>
    <map property="Quantity"></map>
  </type>

  <type name="ProductItem" source="Ordering.BusinessLayer.Product"
        reverseMapping="referenceOnly">
    <map property="Id" identifier="true"></map>
    <map property="Label"></map>
    <map property="Description"></map>
    <map property="SalePrice"></map>
  </type>

</mapping>
